﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyHocPhi.BLL;
using QuanLyHocPhi.Model;
using QuanLyHocPhi.GUI.DuLieu;

namespace QuanLyHocPhi.GUI.TacNghiep
{
    public partial class FormChinhSuaNgayThu : Form
    {
        List<ThongKePhieuThu> dsPhieuThu;
        public FormChinhSuaNgayThu()
        {
            InitializeComponent();
        }
        public FormChinhSuaNgayThu(object listPhieuThu)
        {
            InitializeComponent();
            dsPhieuThu = (List<ThongKePhieuThu>)listPhieuThu;
        }

        private void bntLuu_Click(object sender, EventArgs e)
        {

            FormProgress frm = new FormProgress();
            frm.DoWork += delegate(object oSender, DoWorkEventArgs oE)
            {
                if (dsPhieuThu != null)
                {
                    foreach (var item in dsPhieuThu)
                    {
                        var pt = new PhieuThu() { MaPhieuThu = item.MaPhieuThu, NgayThu = ngayThu.Value };
                        BizPhieuThu.UpdateNgayThu(pt);
                    }
                }
            };
            frm.RunWorkerCompleted += delegate(object oSender, RunWorkerCompletedEventArgs oE)
            {
                if (oE.Error != null)
                {
                    string msg = oE.Error.Message;
                    if (oE.Error.InnerException != null)
                        msg += oE.Error.InnerException.Message;
                    DialogUtils.ShowError(msg);
                }
            };
            frm.StartWorking(this);

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void bntCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
